<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'home';
if($_RQ['op']=='home'){
	exi('','','/home/');
}
if($_RQ['op']=='getnewlog'){
	$chatid = trim($_RQ['chatid']);
	$lastid = intval($_RQ['lastid']);
	$info = pdo_get('jy_kefu_chatlog',array('id >'=>$lastid,'uniacid'=>$_SESSION['uniacid'],'chatid'=>$chatid));
	if($info){
		if($_SESSION['os']=='windows'){
				$htmltime = '<div class="message_box_time">'.$info['createtime'].'</div>';
				if($info['type'] == 1){
					$html .= $htmltime;
						if($info['setmid'] != $_SESSION['uid']){
							$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><p>'.$info['msg'].'</p></div></div></div>';
						}else{
							$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><p>'.$info['msg'].'</p></div></div></div>';
						}
						
				}elseif($info['type'] == 3){
					$html .= $htmltime;
					//$info['msg']=tomedia($info['msg']);
					if($info['setmid'] != $_SESSION['uid']){
							$playhtml = '<span ng-show="pagedata.playon == 1" ng-click="pagedata.playon =0" style="display:none;width:'.$info['audioleng'].'rem;text-align:right" class="text kefu-playon"><img src="../core/resource/images/audioplaying.gif"/></span><span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem;text-align:right" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$info['msg'].'\');" class="r clearfix"><img class="pic"/><span>'.$info['audiotime'].'\'\'</span>'.$playhtml.'</div>';
					}else{
							if($info['isread'] != 1){
								$unread = '<span class="unread"></span>';
							}else{
								$unread ='';
							}
							$playhtml = '<span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem" class="text icon jinyunicon icon-shengbo"></span>';
							$html .='<div onclick="playaudio(\''.$info['msg'].'\',\'\','.$info['id'].');" class="l clearfix"><img class="pic"/>'.$playhtml.'<span>'.$info['audiotime'].'\'\'</span>'.$unread.'</div>';
					}
					
				}elseif($info['type'] == 4){
					$info['msg']=tomedia($info['msg']);
						if($info['setmid'] != $_SESSION['uid']){
							$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><p onclick="followewm(\''.$info['msg'].'\');" class="message_content_inner media"><img src="'.$info['msg'].'" style="width:100%;"/></p></div></div>';
						}else{
							$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><p onclick="followewm(\''.$info['msg'].'\');" class="message_content_inner media"><img src="'.$info['msg'].'" style="width:100%;"/></p></div></div>';
						}
				}elseif($info['type'] == 7){
					$fileurl=tomedia($info['msg']);
					$pathinfo=pathinfo($info['msg']);
					$fileicon=$pathinfo[extension];
					$filename=pdo_getcolumn('core_attachment',array('uniacid'=>$_SESSION['uniacid'],'attachment'=>$info['msg']),'title');
					$filename=$filename.'.'.$pathinfo[extension];
					if(strpos($fileicon,'xls')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'pd')){
						$fileicon='icon-pdf';
					}elseif(strpos($fileicon,'do')){
						$fileicon='icon-exl';
					}elseif(strpos($fileicon,'zip') || strpos($fileicon,'rar')){
						$fileicon='icon-zip';
					}else{
						$fileicon='icon-copy';
					}
					$filesize=filesize(ROOT_AT.'/'.$info['msg'])/1000;
					$filesize=$filesize.'kb';
					if($info['setmid'] != $_SESSION['uid']){
						$html .='<div class="message_box"><img class="mssage_box_pic" src="'.$getmemberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div></div>';
					}else{
						$html .='<div class="message_box from_self"><img class="mssage_box_pic" src="'.$memberlogo.'" style="display:inline-block;"/><div class="message_content"><div class="message_content_inner"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div></div>';
					}
				}
			$res['html']= $html;
		}else{
			if($info['type'] == 1){
							if($info['setmid'] == $_SESSION['uid']){
								$html .='<div class="r clearfix"><img class="pic"/><p class="text">'.$info['msg'].'</p></div>';
							}else{
								$html .='<div class="l clearfix"><img class="pic"/><p class="text">'.$info['msg'].'</p></div>';
							}
							$html .= $htmltime;
			}elseif($info['type'] == 3){
						//$info['msg']=tomedia($info['msg']);
						if($info['setmid'] == $_SESSION['uid']){
								$playhtml = '<span ng-show="pagedata.playon == 1" ng-click="pagedata.playon =0" style="display:none;width:'.$info['audioleng'].'rem;text-align:right" class="text kefu-playon"><img src="../core/resource/images/audioplaying.gif"/></span><span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem;text-align:right" class="text icon jinyunicon icon-shengbo"></span>';
								$html .='<div onclick="playaudio(\''.$info['msg'].'\');" class="r clearfix"><img class="pic"/><span>'.$info['audiotime'].'\'\'</span>'.$playhtml.'</div>';
						}else{
								if($info['isread'] != 1){
									$unread = '<span class="unread"></span>';
								}else{
									$unread ='';
								}
								$playhtml = '<span ng-show="pagedata.playon !=1" ng-click="pagedata.playon =1" style="width:'.$info['audioleng'].'rem" class="text icon jinyunicon icon-shengbo"></span>';
								$html .='<div onclick="playaudio(\''.$info['msg'].'\',\'\','.$info['id'].');" class="l clearfix"><img class="pic"/>'.$playhtml.'<span>'.$info['audiotime'].'\'\'</span>'.$unread.'</div>';
						}
						$html .= $htmltime;
			}elseif($info['type'] == 4){
				$info['msg']=tomedia($info['msg']);
						if($info['setmid'] == $_SESSION['uid']){
								$html .='<div class="r clearfix"><img class="pic"/><p onclick="followewm(\''.$info['msg'].'\');" class="textimg"><img style="max-width:100%" src="'.$info['msg'].'"/></p></div>';
						}else{
								$html .='<div class="l clearfix"><img class="pic"/><p onclick="followewm(\''.$info['msg'].'\');" class="textimg"><img style="max-width:100%" src="'.$info['msg'].'"/></p></div>';
						}
			}elseif($info['type'] == 7){
						$fileurl=tomedia($info['msg']);
						$pathinfo=pathinfo($info['msg']);
						$fileicon=$pathinfo[extension];
						$filename=pdo_getcolumn('core_attachment',array('uniacid'=>$_SESSION['uniacid'],'attachment'=>$info['msg']),'title');
						$filename=$filename.'.'.$pathinfo[extension];
						if(strpos($fileicon,'xls')){
							$fileicon='icon-exl';
						}elseif(strpos($fileicon,'pd')){
							$fileicon='icon-pdf';
						}elseif(strpos($fileicon,'do')){
							$fileicon='icon-exl';
						}elseif(strpos($fileicon,'zip') || strpos($fileicon,'rar')){
							$fileicon='icon-zip';
						}else{
							$fileicon='icon-copy';
						}
						$filesize=filesize(ROOT_AT.'/'.$info['msg']).'kb';
						if($info['setmid'] == $_SESSION['uid']){
							$html .='<div class="r clearfix"><img class="pic"/><div class="text"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div>';
						}else{
							$html .='<div class="l clearfix"><img class="pic"/><div class="text"><a href="'.$fileurl.'" target="_blank" class="fui-cell"><div class="text"><div>'.$filename.'</div><div style="font-size:12px">'.$filesize.'</div></div><div class="icon"><i class="icon '.$fileicon.'"></i></div></a></div></div>';
						}
			}
		}
		$res['log']=$info;
		$res['html']=$html;
	}else{
		$res=array('log'=>false);
	}
	exi($res);
}